package com.example.smartcitydemo.ui.home

import androidx.fragment.app.Fragment
import androidx.viewpager2.adapter.FragmentStateAdapter
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseDataBindingHolder
import com.example.smartcitydemo.R
import com.example.smartcitydemo.bean.NewsInfo
import com.example.smartcitydemo.bean.ReplyInfo
import com.example.smartcitydemo.bean.ServiceBean
import com.example.smartcitydemo.databinding.RecyclerHomeServiceBinding
import com.example.smartcitydemo.databinding.RecyclerNewsInfoBinding
import com.example.smartcitydemo.databinding.RecyclerReplyItemBinding

/**
 * @PACKAGE_NAME: com.example.smartcitydemo.ui.home
 * @NAME: Caleb.F
 * @DATE: 2021/11/5 16:47
 * @Email: 1919796283@qq.com
 */
class MyServiceAdapter :
    BaseQuickAdapter<ServiceBean, BaseDataBindingHolder<RecyclerHomeServiceBinding>>(
        R.layout.recycler_home_service
    ) {
    override fun convert(
        holder: BaseDataBindingHolder<RecyclerHomeServiceBinding>,
        item: ServiceBean
    ) {
        holder.dataBinding!!.data = item
    }
}

class MyViewPager2Adapter(val fragment: Fragment, val fragmentList: List<Fragment>) :
    FragmentStateAdapter(fragment) {
    override fun getItemCount(): Int {
        return fragmentList.size
    }

    override fun createFragment(position: Int): Fragment {
        return fragmentList[position]
    }
}


class MyNewsAdapter :
    BaseQuickAdapter<NewsInfo, BaseDataBindingHolder<RecyclerNewsInfoBinding>>(R.layout.recycler_news_info) {
    override fun convert(holder: BaseDataBindingHolder<RecyclerNewsInfoBinding>, item: NewsInfo) {
        holder.dataBinding?.data = item
    }
}


class MyReplyAdapter :
    BaseQuickAdapter<ReplyInfo, BaseDataBindingHolder<RecyclerReplyItemBinding>>(R.layout.recycler_reply_item) {
    override fun convert(holder: BaseDataBindingHolder<RecyclerReplyItemBinding>, item: ReplyInfo) {
        holder.dataBinding!!.data = item
    }

}